package com.woniuxy.controller;

import com.woniuxy.entity.Blog;
import com.woniuxy.entity.Type;
import com.woniuxy.service.TypeService;
import com.woniuxy.utils.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/life/type")
public class TypeController {
    @Autowired
    private TypeService typeServiceImpl;

    /*
    * 查询所有的分类，渲染到分前端类页面
    * */
    @GetMapping("/findAll")
    public ResponseResult<List<Type>> findAll(){
        List <Type> list =typeServiceImpl.findAll();
        return ResponseResult.success(list);
    }

    /*
     * 根据id查询分类
     **/

    @GetMapping("/findById")
    public ResponseResult<Type> findById(@RequestParam("id") Integer id){
        Type type = typeServiceImpl.findById(id);
        return ResponseResult.success(type);
    }


}
